# _*_ coding: utf8
'''
author: ning.luo
create_date: 2019/05/07
last_update: 2019/05/07
'''

import json
import unittest
import requests
from public.myunit import MyTest

class financial_calculate_service(MyTest):
    '''结算费用计算相关接口'''

    headers = {"Content-Type": "application/json", "charset": "utf-8"}

    def test_01_inquire_technical_service_cost(self):
        '''查询技术服务费'''
        url = "http://test-api.intra.casstime.com/rule-calculate-service/financialfee/technicalservicefee"
        params = {
            "supplierCompanyId":"pVmTmJp1x4WuardEEOB"
        }
        response = requests.get(url, params=params, headers=self.headers)
        print("返回结果：",response.text)
        try:
            self.assertEqual(200, response.status_code)
        except Exception as e:
            print("状态码：", response.status_code)
            print("响应结果：", response.text)
            raise e

    def test_02_inquire_invoice_delivery_subsidy(self):
        '''查询开票的快递补贴'''
        url = "http://test-api.intra.casstime.com/rule-calculate-service/financialfee/deliveryallowance"
        params = {
            "garageCompanyId":"11964",
            "supplierCompanyId":"pVmTmJp1x4WuardEEOB",
            "invoiceFee":"500"
        }
        response = requests.get(url, params=params, headers=self.headers)
        print("响应结果：", response.text)
        try:
            self.assertEqual(200, response.status_code)
        except Exception as e:
            print("状态码：", response.status_code)
            print("响应结果：", response.text)
            raise e

    def test_03_inquire_transaction_details(self):
        '''查询交易明细相关费用'''
        url = "http://test-api.intra.casstime.com/rule-calculate-service/financialfee"
        params = {
            "financialCalculateType": "DELIVERY_ALLOWANCE",
            "supplierCompanyId": "100_100735",
            "tradeDetails": [
                {
                    "feeQuality": "COST_ORIGINAL_BRAND",
                    "financeFee": 200,
                    "standerName": "火花塞",
                    "supplierQuotePrice": 200,
                    "tradeDetailId": ""
                }
            ]
        }
        response = requests.post(url, data=json.dumps(params), headers=self.headers)
        print("响应结果：", response.text)
        try:
            self.assertEqual(200, response.status_code)
        except Exception as e:
            print("状态码：", response.status_code)
            print("响应结果：", response.text)
            raise e

    def test_04_add_delivery_allowance_detail(self):
        '''新增快递补贴交易明细'''
        url = "http://test-api.intra.casstime.com/bill-incomeandexpenses-service/costdetail/deliveryallowance"
        params = {
            "garageCompanyId": "14305",
            "invoiceFee": 1558.737341410221,
            "invoiceId": "DI21000",
            "supplierCompanyId": "100_100735"
        }
        response = requests.post(url, data=json.dumps(params), headers=self.headers)
        print("响应结果：", response.text)
        print("状态码：", response.status_code)

    def test_05_add_cost_detail(self):
        '''新增支出费用明细'''
        url = "http://test-api.intra.casstime.com/bill-incomeandexpenses-service/costdetail/dingtalk"
        params = {
            "agreeTime": "",
            "formItems": [
                {
                    "name": "",
                    "value": ""
                }
            ],
            "id": "",
            "processCode": ""
        }
        response = requests.post(url, data=json.dumps(params), headers=self.headers)
        print("响应结果：", response.text)
        print("状态码：", response.status_code)

    def test_06_get_bill_group_info(self):
        '''查询账单分组列表（账单总表）'''
        url = "http://test-api.intra.casstime.com/bill-incomeandexpenses-service/costbill/group/list"
        params = {
            "costBillId": "",
            "userLoginId": "",
            "page": "",
            "size": ""
        }
        dict={
            "applicant": "",
            "applicationReason": "",
            "billType": "",
            "buyerCompanyId": "",
            "buyerName": "",
            "costBillId": "",
            "costTotalAmount": "",
            "dealTotalAmount": "",
            "dealTypeId": "",
            "sellerCompanyId": "",
            "sellerName":""
        }
        response = requests.post(url, data=json.dumps(params), headers=self.headers)
        print("响应结果：", response.text)
        print("状态码：", response.status_code)

if __name__ == "__main__":
    unittest.main()